Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@polkadot/util-crypto

Package Overview
Dependencies
Maintainers
1
Versions
1357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot/util-crypto

A collection of useful crypto utilities for @polkadot

  • 0.32.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
96K
decreased by-12.74%
Maintainers
1
Weekly downloads
 
Created
Source

@polkadot/util-crypto

Various useful cyrpto utility functions that are used across all projects in the @polkadot namespace. It provides utility functions with additional safety checks, allowing not only for consistent coding, but also reducing the general boilerplate.

Usage

Installation -

yarn add @polkadot/util-crypto

Functions can be imported as follows:

import { mnemonicGenerate } from '@polkadot/util-crypto';

Documentation and Available Utilities

Below is a list of currently exposed methods published at the Polkadot-JS Common Documentation Portal.

Blake2b

  • Creates a blake2b u8a output containing a hash from a u8a input bytes using given bit-length or default bit-length of 256. An optional key u8a of up to 64 bytes may be provided
  • Creates a blake2b hex string with optionally specified bit-length from the u8a input or default bit-length used is 256
  • Uses the Blake2b hash function of blakejs library
  • Note: All hashes used in Polkadot-JS are 32 bytes (i.e. 256 / 8)
  • Note: BLAKE hash functions are in the Nacl library
  • Note: Only handles up to 2**53 bytes of input

Keccak

  • Creates a Keccak-256 hex string from the input (such as for conversion from seed phrase)
  • Creates a Keccak-256 Uint8Array from the input
  • Uses the Keccak-256 hash function from the js-sha3 library

Mnemonic

  • Generate valid mnemonics (for account seed phrase) using BIP39
  • Converts mnemonics to a valid seed secret with Uint8Array output

Nacl

  • Implements NaCl secret-key authenticated encryption, public-key authenticated encryption, hashing, and public-key signatures
  • Decrypts a message that has been encrypted with a secret key using Nacl
  • Encrypts a message with a secret key and generates an associated nonce using Nacl
  • Signing a message with a secret key to generate a valid signature using Nacl
  • Verifies a signed message by providing the message, signature, and public key (associated with the secret key that signed it) using Nacl

Random

  • Returns a sequence of secure random bytes in a variety of formats
  • Creates a u8a with a specified (optional) bit-length (default 32) filled with random bytes
  • Creates a hex string with a specified (optional) bit-length (default 32) filled with random bytes
  • Creates a random number from random secure bytes

SHA-512

  • Implements SHA-512 hashing functions for a variety of input and outputs
  • Creates a SHA-512 hash of u8a input
  • Uses the SHA-512 hash function of tweetnacl library

xxHash

  • Create xxhash64 values with specified bitlengths
  • Creates a xxhash64 u8a from the input with a specified (optional) bit-length (default 64)
  • Creates a xxhash64 hex string from the input with a specified (optional) bit-length (default 64)
  • Uses xxHash to generate values as BN, hex & number output

Keywords

FAQs

Package last updated on 21 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc